
<?php

/**
 *      [品牌空间] (C)2001-2010 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: store.php 5743 2011-10-08 01:51:32Z menglingmin $
 */

define("CURSCRIPT", "map");

require_once('./common.php');
require_once(B_ROOT.'./source/adminfunc/brandpost.func.php');

$catid = intval($_GET['catid']);
$defaultshopmap = '(39.917,116.397)';
$draggable = 'true';
$mapshop = array();
if($catid) {

	$query = DB::query("SELECT i.itemid,i.subject,i.address,i.tel,m.mapapimark FROM ".DB::table('shopitems')." i LEFT JOIN ".DB::table('shopmessage')." m ON i.itemid=m.itemid WHERE i.catid='".$catid."' AND m.mapapimark!='' AND i.grade>2 ORDER BY i.displayorder DESC LIMIT 10");
	while($row = DB::fetch($query)) {
		$mapshop['info'][] = "<b><a href='store.php?id=".$row['itemid']."' target='_blank'>".$row['subject']."</a></b><br />".$lang['telephone'].$row['tel']."<br />".$lang['address'].$row['address'];
		$row['mapapimark'] = preg_replace('/\(/', '', $row['mapapimark']);
		$row['mapapimark'] = preg_replace('/\)/', '', $row['mapapimark']);
		$mapshop['mark'][] = $row['mapapimark'];
		$mapshop['title'][] = $row['subject'];
	}
	if($mapshop['mark'][0] == '') {
		$returndata = 0;
	} else {
		$info_shop = implode(" ^ ", $mapshop['info']);
		$mark_shop = implode(" ^ ", $mapshop['mark']);
		$shoptitle = implode(" ^ ", $mapshop['title']);
		$returndata = $info_shop.' | '.$mark_shop.' | '.$shoptitle;
		if($_SC['charset'] == 'gbk'){
			$returndata = iconv("gbk","utf-8",$returndata);
		}
	}
	echo $returndata;
	exit;
} else {
	$markshop = array();

	$query = DB::query("SELECT i.itemid,i.subject,i.address,i.tel,i.discount,m.mapapimark FROM ".DB::table('shopitems')." i LEFT JOIN ".DB::table('shopmessage')." m ON i.itemid=m.itemid WHERE m.mapapimark!='' AND i.grade>2 ORDER BY i.displayorder ASC,i.itemid DESC LIMIT 10");
	while($row = DB::fetch($query)) {
		if($row['discount']) {
			$tmpstr = "<br />".$lang['groupbuydiscount'].$lang['colon'].cutstr($row['discount'], 20);
		} else {
			$tmpstr = ' ';
		}
		$mapshop['info'][] = "<b><a href='store.php?id=".$row['itemid']."' target='_blank'>".$row['subject']."</a></b><br />".$lang['telephone'].$row['tel']."<br />".$lang['address'].$row['address'].$tmpstr;
		$row['mapapimark'] = preg_replace('/\(/', '', $row['mapapimark']);
		$row['mapapimark'] = preg_replace('/\)/', '', $row['mapapimark']);
		$mapshop['mark'][] = $row['mapapimark'];
		$mapshop['title'][] = $row['subject'];
	}
	$shoptitle = implode(" ^ ", $mapshop['title']);
	$info_shop = implode(" ^ ", $mapshop['info']);
	$str_shop = implode(" ^ ", $mapshop['mark']);
	$inmap = true;
	include template('templates/site/default/map.html.php', 1);	
	
}



ob_out(); //正则处理url/模板


?>

